/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tv.inventario.modelo;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author Claudio
 */
@Entity
@Table(name = "USR_PRDSUS",schema = "dbo")
public class Sustitutos implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SustitutosPK sustitutosPK;
    
    @Column(name = "USR_PRDSUS_NROITM")
    private Short usrPrdsusNroitm;

    @ManyToOne(optional = false)
    @JoinColumns({
        @JoinColumn(name = "USR_PRDSUS_TIPSUS", referencedColumnName = "STMPDH_TIPPRO", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "USR_PRDSUS_ARTSUS", referencedColumnName = "STMPDH_ARTCOD", nullable = false,insertable=false, updatable=false)
    })
    private Producto productoSustituto;

    @ManyToOne(optional = false)
    @JoinColumns({
        @JoinColumn(name = "USR_PRDSUS_TIPPRO", referencedColumnName = "STMPDH_TIPPRO", nullable = false,insertable=false, updatable=false),
        @JoinColumn(name = "USR_PRDSUS_ARTCOD", referencedColumnName = "STMPDH_ARTCOD", nullable = false,insertable=false, updatable=false)
    })
    private Producto productoPrincipal;

    @Column(name = "USR_PR_DEBAJA")
    private Character debaja;

    public Sustitutos() {
    }

    public Sustitutos(SustitutosPK sustitutosPK) {
        this.sustitutosPK = sustitutosPK;
    }

    public Sustitutos(String usrPrdsusTippro, String usrPrdsusArtcod, String usrPrdsusTipsus, String usrPrdsusArtsus) {
        this.sustitutosPK = new SustitutosPK(usrPrdsusTippro, usrPrdsusArtcod, usrPrdsusTipsus, usrPrdsusArtsus);
    }

    public SustitutosPK getSustitutosPK() {
        return sustitutosPK;
    }

    public void setSustitutosPK(SustitutosPK sustitutosPK) {
        this.sustitutosPK = sustitutosPK;
    }

    public Short getUsrPrdsusNroitm() {
        return usrPrdsusNroitm;
    }

    public void setUsrPrdsusNroitm(Short usrPrdsusNroitm) {
        this.usrPrdsusNroitm = usrPrdsusNroitm;
    }

    public Character getDebaja() {
        return debaja;
    }

    public void setDebaja(Character debaja) {
        this.debaja = debaja;
    }

    public Producto getProductoPrincipal() {
        return productoPrincipal;
    }

    public void setProductoPrincipal(Producto productoPrincipal) {
        this.productoPrincipal = productoPrincipal;
    }

    public Producto getProductoSustituto() {
        return productoSustituto;
    }

    public void setProductoSustituto(Producto productoSustituto) {
        this.productoSustituto = productoSustituto;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sustitutosPK != null ? sustitutosPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sustitutos)) {
            return false;
        }
        Sustitutos other = (Sustitutos) object;
        if ((this.sustitutosPK == null && other.sustitutosPK != null) || (this.sustitutosPK != null && !this.sustitutosPK.equals(other.sustitutosPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "tv.inventario.modelo.Sustitutos[sustitutosPK=" + sustitutosPK + "]";
    }

}
